﻿namespace PhotobucketNet
{
    using System;
    using System.Xml;

    public class MediaTag
    {
        private float _bottomRightX;
        private float _bottomRightY;
        private string _contact;
        private int _count;
        private string _name;
        private int _tagId;
        private float _topLeftX;
        private float _topLeftY;
        private string _url;

        private MediaTag()
        {
            this._name = string.Empty;
            this._count = -1;
            this._tagId = -1;
            this._topLeftX = -1f;
            this._topLeftY = -1f;
            this._bottomRightX = -1f;
            this._bottomRightY = -1f;
            this._contact = string.Empty;
            this._url = string.Empty;
        }

        public MediaTag(string name)
        {
            this._name = string.Empty;
            this._count = -1;
            this._tagId = -1;
            this._topLeftX = -1f;
            this._topLeftY = -1f;
            this._bottomRightX = -1f;
            this._bottomRightY = -1f;
            this._contact = string.Empty;
            this._url = string.Empty;
            this._name = name;
        }

        internal static MediaTag CreateFromXmlNode(XmlNode mediaTagNode)
        {
            MediaTag tag = new MediaTag();
            XmlNode node = mediaTagNode.SelectSingleNode("descendant::name");
            tag._name = (node == null) ? string.Empty : node.InnerText;
            XmlNode node2 = mediaTagNode.SelectSingleNode("descendant::count");
            tag._count = (node2 == null) ? -1 : Convert.ToInt32(node2.InnerText);
            XmlNode node3 = mediaTagNode.SelectSingleNode("descendant::tag");
            tag._name = (node3 == null) ? string.Empty : node3.InnerText;
            XmlNode node4 = mediaTagNode.SelectSingleNode("descendant::tagid");
            tag._tagId = (node4 == null) ? -1 : Convert.ToInt32(node4.InnerText);
            XmlNode node5 = mediaTagNode.SelectSingleNode("descendant::topLeftXCoord");
            tag._topLeftX = (node5 == null) ? -1f : Convert.ToSingle(node5.InnerText);
            XmlNode node6 = mediaTagNode.SelectSingleNode("descendant::topLeftYCoord");
            tag._topLeftY = (node6 == null) ? -1f : Convert.ToSingle(node6.InnerText);
            XmlNode node7 = mediaTagNode.SelectSingleNode("descendant::bottomRightXCoord");
            tag._bottomRightX = (node7 == null) ? -1f : Convert.ToSingle(node7.InnerText);
            XmlNode node8 = mediaTagNode.SelectSingleNode("descendant::bottomRightYCoord");
            tag._bottomRightY = (node8 == null) ? -1f : Convert.ToSingle(node8.InnerText);
            XmlNode node9 = mediaTagNode.SelectSingleNode("descendant::contact");
            tag._contact = (node9 == null) ? string.Empty : node9.InnerText;
            XmlNode node10 = mediaTagNode.SelectSingleNode("descendant::url");
            tag._url = (node10 == null) ? string.Empty : node10.InnerText;
            return tag;
        }

        public float BottomRightX
        {
            get
            {
                return this._bottomRightX;
            }
            set
            {
                this._bottomRightX = value;
            }
        }

        public float BottomRightY
        {
            get
            {
                return this._bottomRightY;
            }
            set
            {
                this._bottomRightY = value;
            }
        }

        public string Contact
        {
            get
            {
                return this._contact;
            }
            set
            {
                this._contact = value;
            }
        }

        public int Count
        {
            get
            {
                return this._count;
            }
            set
            {
                this._count = value;
            }
        }

        public string Name
        {
            get
            {
                return this._name;
            }
            set
            {
                this._name = value;
            }
        }

        public int TagId
        {
            get
            {
                return this._tagId;
            }
            set
            {
                this._tagId = value;
            }
        }

        public float TopLeftX
        {
            get
            {
                return this._topLeftX;
            }
            set
            {
                this._topLeftX = value;
            }
        }

        public float TopLeftY
        {
            get
            {
                return this._topLeftY;
            }
            set
            {
                this._topLeftY = value;
            }
        }

        public string Url
        {
            get
            {
                return this._url;
            }
            set
            {
                this._url = value;
            }
        }
    }
}

